package com.woniu.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.dao.CoursewareDao;
import com.woniu.domain.Courseware;
import com.woniu.domain.WareCation;
import com.woniu.service.CoursewareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursewareServiceImpl implements CoursewareService {
    @Autowired(required = false)
    CoursewareDao coursewareDao;

    @Override
    public Courseware getCourseById(Integer coursewareId) {
        return coursewareDao.getCourseById(coursewareId);
    }


    @Override
    public int addCourseware(Courseware courseware) {
        return coursewareDao.addCourseware(courseware);
    }

    /**
     * 修改
     * @param courseware
     * @return
     */
    @Override
    public int updateCourseware(Courseware courseware) {
        return coursewareDao.updateCourseware(courseware);
    }

    //分页
    @Override
    public PageInfo<Courseware> findCoursewareByPage(Integer startpage, Integer pagesize) {
        PageHelper.startPage(startpage,pagesize);
        List<Courseware> wareList=coursewareDao.findCoursewareByPage();
        PageInfo<Courseware> warePage=new PageInfo<>(wareList);
        return warePage;
    }
    //根据id删除课件
    @Override
    public void delWareById(Integer coursewareId) {
        coursewareDao.delWareById(coursewareId);
    }

    //搜索
    @Override
    public List<Courseware> getCourseByCondition(Courseware obj) {
        return coursewareDao.getCourseByCondition(obj);
    }

    //课件分类
    @Override
    public List<WareCation> wareQuery() {
        return coursewareDao.cationQuery();
    }


    @Override
    public int batchUpdateCourseware(List<Courseware> coursewares) {
        return coursewareDao.batchUpdateCourseware(coursewares);
    }

    @Override
    //查询所有没有对应章节的课件
    public List<Courseware> coursewareQuery() {
        return coursewareDao.coursewareQuery();
    }

    @Override
    public List<Courseware> getDate(Integer courseId) {
        return coursewareDao.getDate(courseId);
    }
}
